var ddaccordion = {
    ajaxloadingmsg: '<img src="loading2.gif" /><br />Loading Content...',
    headergroup: {},
    contentgroup: {},
    preloadimages: function(a) {
        a.each(function() {
            var a = new Image();
            a.src = this.src;
        });
    },
    expandone: function(a, b) {
        this.toggleone(a, b, "expand");
    },
    collapseone: function(a, b) {
        this.toggleone(a, b, "collapse");
    },
    expandall: function(a) {
        var b = this.headergroup[a];
        this.contentgroup[a].filter(":hidden").each(function() {
            b.eq(parseInt($(this).attr("contentindex"))).trigger("evt_accordion");
        });
    },
    collapseall: function(a) {
        var b = this.headergroup[a];
        this.contentgroup[a].filter(":visible").each(function() {
            b.eq(parseInt($(this).attr("contentindex"))).trigger("evt_accordion");
        });
    },
    toggleone: function(a, b, c) {
        var d = this.headergroup[a].eq(b), e = this.contentgroup[a].eq(b);
        ("undefined" == typeof c || "expand" == c && e.is(":hidden") || "collapse" == c && e.is(":visible")) && d.trigger("evt_accordion");
    },
    ajaxloadcontent: function(a, b, c, d) {
        function f(a) {
            a && (e.cacheddata = a, e.status = "cached", 0 == b.queue("fx").length && (b.hide().html(a), 
            e.status = "complete", d())), "complete" != e.status && setTimeout(function() {
                f(e.cacheddata);
            }, 100);
        }
        var e = a.data("ajaxinfo");
        "none" == e.status ? (b.html(this.ajaxloadingmsg), b.slideDown(c.animatespeed), 
        e.status = "loading", $.ajax({
            url: e.url,
            error: function(a) {
                f("Error fetching content. Server Response: " + a.responseText);
            },
            success: function(a) {
                a = "" == a ? " " : a, f(a);
            }
        })) : "loading" == e.status && f(e.cacheddata);
    },
    expandit: function(a, b, c, d, e, f) {
        var g = a.data("ajaxinfo");
        g && ("none" == g.status || "loading" == g.status ? this.ajaxloadcontent(a, b, c, function() {
            ddaccordion.expandit(a, b, c, d, e);
        }) : "cached" == g.status && (b.html(g.cacheddata), g.cacheddata = null, g.status = "complete")), 
        this.transformHeader(a, c, "expand"), b.slideDown(f ? 0 : c.animatespeed, function() {
            if (c.onopenclose(a.get(0), parseInt(a.attr("headerindex")), b.css("display"), d), 
            "gotourl" == c.postreveal && e) {
                var f = a.is("a") ? a.get(0) : a.find("a:eq(0)").get(0);
                f && setTimeout(function() {
                    location = f.href;
                }, 200);
            }
        });
    },
    collapseit: function(a, b, c, d) {
        this.transformHeader(a, c, "collapse"), b.slideUp(c.animatespeed, function() {
            c.onopenclose(a.get(0), parseInt(a.attr("headerindex")), b.css("display"), d);
        });
    },
    transformHeader: function(a, b, c) {
        a.addClass("expand" == c ? b.cssclass.expand : b.cssclass.collapse).removeClass("expand" == c ? b.cssclass.collapse : b.cssclass.expand), 
        "src" == b.htmlsetting.location ? (a = a.is("img") ? a : a.find("img").eq(0), a.attr("src", "expand" == c ? b.htmlsetting.expand : b.htmlsetting.collapse)) : "prefix" == b.htmlsetting.location ? a.find(".accordprefix").html("expand" == c ? b.htmlsetting.expand : b.htmlsetting.collapse) : "suffix" == b.htmlsetting.location && a.find(".accordsuffix").html("expand" == c ? b.htmlsetting.expand : b.htmlsetting.collapse);
    },
    urlparamselect: function(a) {
        var b = window.location.search.match(new RegExp(a + "=((\\d+)(,(\\d+))*)", "i"));
        return null != b && (b = RegExp.$1.split(",")), b;
    },
    getCookie: function(a) {
        var b = new RegExp(a + "=[^;]+", "i");
        return document.cookie.match(b) ? document.cookie.match(b)[0].split("=")[1] : null;
    },
    setCookie: function(a, b) {
        document.cookie = a + "=" + b + "; path=/";
    },
    init: function(a) {
        document.write('<style type="text/css">\n'), document.write("." + a.contentclass + "{display: none}\n"), 
        document.write("a.hiddenajaxlink{display: none}\n"), document.write("</style>"), 
        jQuery(document).ready(function(b) {
            var c, d, e, f, g;
            ddaccordion.urlparamselect(a.headerclass), c = ddaccordion.getCookie(a.headerclass), 
            ddaccordion.headergroup[a.headerclass] = b("." + a.headerclass), ddaccordion.contentgroup[a.headerclass] = b("." + a.contentclass), 
            d = ddaccordion.headergroup[a.headerclass], e = ddaccordion.contentgroup[a.headerclass], 
            a.cssclass = {
                collapse: a.toggleclass[0],
                expand: a.toggleclass[1]
            }, a.revealtype = a.revealtype || "click", a.revealtype = a.revealtype.replace(/mouseover/i, "mouseenter"), 
            "clickgo" == a.revealtype && (a.postreveal = "gotourl", a.revealtype = "click"), 
            a.htmlsetting = "undefined" == typeof a.togglehtml ? {
                location: "none"
            } : {
                location: a.togglehtml[0],
                collapse: a.togglehtml[1],
                expand: a.togglehtml[2]
            }, a.oninit = "undefined" == typeof a.oninit ? function() {} : a.oninit, a.onopenclose = "undefined" == typeof a.onopenclose ? function() {} : a.onopenclose, 
            f = {}, g = ddaccordion.urlparamselect(a.headerclass) || (a.persiststate && null != c ? c : a.defaultexpanded), 
            "string" == typeof g && (g = g.replace(/c/gi, "").split(",")), 1 == g.length && "-1" == g[0] && (g = []), 
            a.collapseprev && g.length > 1 && (g = [ g.pop() ]), a.onemustopen && 0 == g.length && (g = [ 0 ]), 
            d.each(function(c) {
                var h, i, j, d = b(this);
                /(prefix)|(suffix)/i.test(a.htmlsetting.location) && "" != d.html() && (b('<span class="accordprefix"></span>').prependTo(this), 
                b('<span class="accordsuffix"></span>').appendTo(this)), d.attr("headerindex", c + "h"), 
                e.eq(c).attr("contentindex", c + "c"), h = e.eq(c), i = h.find("a.hiddenajaxlink:eq(0)"), 
                1 == i.length && d.data("ajaxinfo", {
                    url: i.attr("href"),
                    cacheddata: null,
                    status: "none"
                }), j = "number" == typeof g[0] ? c : c + "", -1 != jQuery.inArray(j, g) ? (ddaccordion.expandit(d, h, a, !1, !1, !a.animatedefault), 
                f = {
                    $header: d,
                    $content: h
                }) : (h.hide(), a.onopenclose(d.get(0), parseInt(d.attr("headerindex")), h.css("display"), !1), 
                ddaccordion.transformHeader(d, a, "collapse"));
            }), d.bind("evt_accordion", function(c, d) {
                var g = e.eq(parseInt(b(this).attr("headerindex")));
                "none" == g.css("display") ? (ddaccordion.expandit(b(this), g, a, !0, d), a.collapseprev && f.$header && b(this).get(0) != f.$header.get(0) && ddaccordion.collapseit(f.$header, f.$content, a, !0), 
                f = {
                    $header: b(this),
                    $content: g
                }) : (!a.onemustopen || a.onemustopen && f.$header && b(this).get(0) != f.$header.get(0)) && ddaccordion.collapseit(b(this), g, a, !0);
            }), d.bind(a.revealtype, function() {
                if ("mouseenter" != a.revealtype) return b(this).trigger("evt_accordion", [ !0 ]), 
                !1;
                clearTimeout(a.revealdelay);
                var c = parseInt(b(this).attr("headerindex"));
                a.revealdelay = setTimeout(function() {
                    ddaccordion.expandone(a.headerclass, c);
                }, a.mouseoverdelay || 0);
            }), d.bind("mouseleave", function() {
                clearTimeout(a.revealdelay);
            }), a.oninit(d.get(), g), b(window).bind("unload", function() {
                d.unbind();
                var c = [];
                e.filter(":visible").each(function() {
                    c.push(b(this).attr("contentindex"));
                }), 1 == a.persiststate && d.length > 0 && (c = 0 == c.length ? "-1c" : c, ddaccordion.setCookie(a.headerclass, c));
            });
        });
    }
};

ddaccordion.preloadimages(jQuery(ddaccordion.ajaxloadingmsg).filter("img")), ddaccordion.init({
    headerclass: "expandable",
    contentclass: "categoryitems",
    revealtype: "click",
    mouseoverdelay: 200,
    collapseprev: !0,
    defaultexpanded: [ 0 ],
    onemustopen: !1,
    animatedefault: !1,
    persiststate: !0,
    toggleclass: [ "", "openheader" ],
    togglehtml: [ "prefix", "", "" ],
    animatespeed: "fast",
    oninit: function() {},
    onopenclose: function() {}
}), $(function() {
    $(".categoryitems li").each(function() {
        $(this).find("li").length > 0 ? ($(this).find("span").addClass("spanParentStyle"), 
        $(this).find("ul").hide(), $(this).find("ul").find("ul").hide(), $(this).parent().parent("li").length > 0 ? $(this).find("a").eq(0).click(function() {
            $(this).parent().find("ul").slideDown();
        }) : $(this).find("a").eq(0).click(function() {
            "none" == $(this).parent().find("ul").eq(0)[0].style.display ? ($(this).parents(".arrowlistmenu").find("li").find("ul").hide(), 
            $(this).parent().find("ul").eq(0).slideDown()) : $(this).parent().find("ul").eq(0).slideUp();
        })) : $(this).find("span").addClass("spanStyle");
    }), $(".categoryitems >li").each(function() {
        $(this).find("a").eq(0).click(function() {
            $(this).parents(".arrowlistmenu").find("li").find("a").removeClass("arrowlistmenuCurrent"), 
            $(this).addClass("arrowlistmenuCurrent");
        }), $(this).find("li").find("a").click(function() {
            $(this).parents(".arrowlistmenu").find("li").find("a").removeClass("arrowlistmenuCurrent"), 
            $(this).addClass("arrowlistmenuCurrent");
        });
    });
}), $(function() {
    var a, b;
    $(".nav_icon_v_item").length > 0 && (a = 0, b = jQuery.jCookie("navIconVIndex"), 
    0 != b && (a = parseInt(b)), $(".nav_icon_v_item >a").filter(":eq(" + a + ")").addClass("current"), 
    $(".nav_icon_v_item >a").each(function(a) {
        $(this).click(function() {
            $(".nav_icon_v_item >a").removeClass("current"), $(this).addClass("current"), jQuery.jCookie("navIconVIndex", a.toString());
        });
    }));
});